package com.tcfvic.client.panels;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.VerticalSplitPanel;
import com.tcfvic.client.TrainingListService;
import com.tcfvic.client.TrainingListServiceAsync;
import com.tcfvic.client.panels.widgets.TrainingDetailsInputWidget;
import com.tcfvic.client.panels.widgets.TrainingListWidget;

public class TrainingDetailsForm {

	/**
	 * Create a remote service proxy to talk to the server-side PersonDetails
	 * service.
	 */
	private final TrainingListServiceAsync trainingService = GWT
			.create(TrainingListService.class);
	private VerticalSplitPanel vSplit = new VerticalSplitPanel();

	public TrainingDetailsForm(boolean editing) {
		// Create a Vertical Split Panel
		vSplit = new VerticalSplitPanel();
		vSplit.ensureDebugId("cwVerticalSplitPanel");
		vSplit.setSize("900px", "800px");
		vSplit.setSplitPosition("1%");

		TrainingDetailsInputWidget trainingDetails = new TrainingDetailsInputWidget();
		TrainingListWidget trainingListWidget = null;
		if (editing) {
			trainingListWidget = new TrainingListWidget(
					trainingService, trainingDetails);
			vSplit.setTopWidget(trainingListWidget);
			vSplit.setSplitPosition("42%");
		}
		trainingDetails.addTrainingDetailsList(trainingListWidget);
		vSplit.setBottomWidget(trainingDetails);

	}

	public VerticalSplitPanel getvSplit() {
		return vSplit;
	}
}
